home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Programming / JForth / JTools / DevTools / unused < prev    next >
Encoding:
Text File  |  1988-09-09  |  1.6 KB  |  87 lines

  1. \ Mark words as used when compiling.
  2. \ This is useful for finding out which words can be eliminated
  3. \ from a file to save space and can also catch bugs.
  4. \
  5. \ Author: Phil Burk
  6. \ Copyright 1986 Delta Research
  7. \
  8. \ MOD: PLB 9/9/88 use if.forgotten
  9.  
  10. include? USED_BIT ju:sfa_bits
  11.  
  12.  
  13. ANEW TASK-UNUSED
  14.  
  15. .need used_bit
  16. $ 2000,0000 constant USED_BIT
  17. .then
  18.  
  19. : MARK.USED ( cfa -- )
  20.     cell- dup @
  21.     used_bit or swap !
  22. ;
  23.  
  24. : MARK.UNUSED ( cfa -- )
  25.     cell- dup @
  26.     used_bit comp and swap !
  27. ;
  28.  
  29. USER OLD-FIND-CFA
  30.  
  31. : (MARK.FIND) ( string -- string false | cfa true )
  32.     old-find-cfa @execute dup
  33.     IF over mark.used
  34.     THEN
  35. ;
  36.  
  37. : (CLEAR.MARKS) ( nfa -- , clear mark for word )
  38.     name> mark.unused
  39. ;
  40. : SCAN-WITH ( cfa -- , scan dictionary with cfa )
  41.     dup is when-scanned
  42.     is when-voc-scanned
  43.     scan-words
  44. ;
  45.  
  46. : CLEAR.MARKS ( -- , clear marks on words )
  47.    ' (clear.marks) scan-with
  48. ;
  49.  
  50. : START.MARKING.WORDS  ( -- , Mark all subsequently found words. )
  51.     old-find-cfa @ 0=
  52.     IF  what's find  old-find-cfa !
  53.         ' (mark.find) is find
  54.     THEN
  55. ;
  56.  
  57. : STOP.MARKING.WORDS  ( -- , Mark all subsequently found words. )
  58.     old-find-cfa @
  59.     IF  old-find-cfa @ is find
  60.         0 old-find-cfa !
  61.     THEN
  62. ;
  63.  
  64. : (PRINT.UNUSED) ( nfa -- , print if not used )
  65.     dup name> cell- @ used_bit and
  66.     IF   drop
  67.     ELSE ID.lIST \ cr? id. space space
  68.     THEN
  69. ;
  70.  
  71. : UNUSED.WORDS ( -- , print unused words )
  72.     ' (print.unused) scan-with
  73. ;
  74.  
  75. : (PRINT.USED) ( nfa -- , print if not used )
  76.     dup name> cell- @ used_bit and
  77.     IF   ID.LIST  \ cr? id. space space
  78.     ELSE drop
  79.     THEN
  80. ;
  81.  
  82. : USED.WORDS ( -- , print unused words )
  83.     ' (print.used) scan-with
  84. ;
  85.  
  86. if.forgotten stop.marking.words
  87.